package com.sinosoft.hydra.um.domain.permission;

import com.alibaba.fastjson.annotation.JSONField;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "T_PROCESS_RECORD")
@Inheritance(strategy = InheritanceType.JOINED)
public class TProcessRecord implements Serializable {
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.id
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @Size(max = 50, message = "tprocessrecord.id.max.overflow")
    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "ID")
    private String id;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.operate_time
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @Column(name = "OPERATE_TIME")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date operateTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.operate_time
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @Column(name = "CREATE_TIME")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.operator
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @Size(max = 400, message = "tprocessrecord.operator.max.overflow")
    @Column(name = "OPERATOR")
    private String operator;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.operator
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @NotNull(message = "tprocessrecord.createuser.not.null")
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "CREATE_USER")
    @NotFound(action = NotFoundAction.IGNORE)
    private SysUserMember createUser;

    public SysUserMember getCreateUser() {
        return createUser;
    }

    public void setCreateUser(SysUserMember createUser) {
        this.createUser = createUser;
    }

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.process_template
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "PROCESS_TEMPLATE")
    private TProcessTemplate tProcessTemplate;


    @OneToOne(mappedBy = "tProcessRecord", cascade = CascadeType.DETACH)
    private TExperimentalData tExperimentalData;

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.DETACH)
    @JoinTable(name = "T_E_BOM_RECORD"    //中间表的表名
            , joinColumns = @JoinColumn(name = "RECORD_ID")    //指向本端的外键
            , inverseJoinColumns = @JoinColumn(name = "E_BOM_ID"))    //指向对方端的外键
    private List<TEBom> teBoms;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_record.result
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @Size(max = 400, message = "tprocessrecord.result.max.overflow")
    @Column(name = "RESULT")
    private String result;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database table t_process_record
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    private static final long serialVersionUID = 1L;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_process_parameter.process_record
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    @OneToMany(cascade = CascadeType.DETACH, mappedBy = "tProcessRecord")
    private List<TProcessParameter> tProcessParameters;

    @NotNull(message = "tprocessrecord.type.not.null")
    @Size(max = 50, message = "tprocessrecord.type.max.overflow")
    @Column(name = "TYPE")
    private String type;


    @Transient
    private boolean updatePermission;

    public boolean isUpdatePermission() {
        return updatePermission;
    }

    public void setUpdatePermission(boolean updatePermission) {
        this.updatePermission = updatePermission;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_record.id
     *
     * @return the value of t_process_record.id
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public String getId() {
        return id;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_record.id
     *
     * @param id the value for t_process_record.id
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_record.create_time
     *
     * @return the value of t_process_record.create_time
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public Date getOperateTime() {
        return operateTime;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_record.create_time
     *
     * @param operateTime the value for t_process_record.create_time
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public void setOperateTime(Date operateTime) {
        this.operateTime = operateTime;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_record.create_user
     *
     * @return the value of t_process_record.create_user
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public String getOperator() {
        return operator;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_record.create_user
     *
     * @param operator the value for t_process_record.create_user
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public void setOperator(String operator) {
        this.operator = operator;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_record.process_template
     *
     * @return the value of t_process_record.process_template
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public TProcessTemplate gettProcessTemplate() {
        return tProcessTemplate;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_record.process_template
     *
     * @param tProcessTemplate the value for t_process_record.process_template
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public void settProcessTemplate(TProcessTemplate tProcessTemplate) {
        this.tProcessTemplate = tProcessTemplate;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_record.result
     *
     * @return the value of t_process_record.result
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public String getResult() {
        return result;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_record.type
     *
     * @return the value of t_process_record.type
     * @mbggenerated Sat Jul 16 10:41:49 CST 2016
     */
    public String getType() {
        return type;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_record.type
     *
     * @param type the value for t_process_record.type
     * @mbggenerated Sat Jul 16 10:41:49 CST 2016
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_record.result
     *
     * @param result the value for t_process_record.result
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public void setResult(String result) {
        this.result = result;
    }

    public List<TEBom> getTeBoms() {
        return teBoms;
    }

    public void setTeBoms(List<TEBom> teBoms) {
        this.teBoms = teBoms;
    }


    @Column(name = "UPDATE_TIME")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_process_record
     *
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", operateTime=").append(operateTime);
        sb.append(", operator=").append(operator);
        sb.append(", tProcessTemplate=").append(tProcessTemplate);
        sb.append(", result=").append(result);
        sb.append(", type=").append(type);

        sb.append("]");
        return sb.toString();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_experimental_data.process_record
     *
     * @return the value of t_experimental_data.process_record
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public TExperimentalData gettExperimentalData() {
        return tExperimentalData;
    }

    public void settExperimentalData(TExperimentalData tExperimentalData) {
        this.tExperimentalData = tExperimentalData;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_process_parameter.process_record
     *
     * @return the value of t_process_parameter.process_record
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public List<TProcessParameter> gettProcessParameters() {
        return tProcessParameters;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_process_parameter.process_record
     *
     * @param tProcessParameters the value for t_process_parameter.process_record
     * @mbggenerated Mon Jul 11 10:58:35 CST 2016
     */
    public void settProcessParameters(List<TProcessParameter> tProcessParameters) {
        this.tProcessParameters = tProcessParameters;
    }
}